An option to make you code more efficient is to exclude unused imports, that is, to optimize them. Select
Optimize Imports... from
the Tools in the main menu, or from the context menu in the
Project View or Commander. Or use the shortcut,
Ctrl + Alt + O.
|
Also there is another mechanism. To launch this action, you can use the
Import Assistant intention action.
|
You will see the following menu:

The option buttons are enabled or disabled depending on where from you have called this action.
'File' option button |
Enabled if the caret is in the editor or a file is selected in a tool window |
'All files in directory' option button |
Optimizes imports in all files in the current directory.
If there are any subdirectories, the Include subdirectories check box appears.
If it is selected, the files in the subdirectories will be reformatted as well.
|
After you press Run, the unused imports will be removed.
|